package com.artron.mediaartron.data.entity;

import com.bigkoo.pickerview.model.IPickerViewData;

import java.util.ArrayList;
import java.util.List;


/**
 * Class description here
 *
 * @author doing
 * @version 1.0.0
 * @since 2017-10-23.
 */

public class Address  {

    private List<Province> provinces;

    public Address() {
        provinces = new ArrayList<>();
    }

    public List<Province> getProvinces() {
        return provinces;
    }

    public void addItem(Province province) {
        provinces.add(province);
    }


    public static class Province implements IPickerViewData{
        private String name;
        private int parentId;
        private int pid;
        private List<City> cityList;

        public Province() {
            cityList = new ArrayList<>();
        }

        public String getName() {
            return name;
        }

        private void setName(String name) {
            this.name = name;
        }

        public int getParentId() {
            return parentId;
        }

        private void setParentId(int parentId) {
            this.parentId = parentId;
        }

        public int getPid() {
            return pid;
        }

        private void setPid(int pid) {
            this.pid = pid;
        }

        public List<City> getCityList() {
            return cityList;
        }

        public void addItem(City city) {
            cityList.add(city);
        }

        public void set(String type, String value) {
            switch (type) {
                case "name":
                    setName(value);
                    break;
                case "parentId":
                    int parentId = Integer.parseInt(value);
                    setParentId(parentId);
                    break;
                case "pid":
                    int pid = Integer.parseInt(value);
                    setPid(pid);
                    break;
            }
        }
        @Override
        public String getPickerViewText() {
            return name;
        }

    }

    public static class City implements IPickerViewData{
        private String name;
        private int parentId;
        private int pid;
        private List<District> districts;

        public City(){
            districts = new ArrayList<>();
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getParentId() {
            return parentId;
        }

        public void setParentId(int parentId) {
            this.parentId = parentId;
        }

        public int getPid() {
            return pid;
        }

        public void setPid(int pid) {
            this.pid = pid;
        }

        public List<District> getDistricts() {
            return districts;
        }

        public void addItem(District district) {
            districts.add(district);
        }


        public void set(String type, String value) {
            switch (type) {
                case "name":
                    setName(value);
                    break;
                case "parentId":
                    int parentId = Integer.parseInt(value);
                    setParentId(parentId);
                    break;
                case "pid":
                    int pid = Integer.parseInt(value);
                    setPid(pid);
                    break;
            }
        }

        @Override
        public String getPickerViewText() {
            return name;
        }
    }

    public static class District implements IPickerViewData {
        private String name;
        private int parentId;
        private int pid;
        private int type;

        public District(){}

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getParentId() {
            return parentId;
        }

        public void setParentId(int parentId) {
            this.parentId = parentId;
        }

        public int getPid() {
            return pid;
        }

        public void setPid(int pid) {
            this.pid = pid;
        }

        public int getType() {
            return type;
        }

        public void setType(int type) {
            this.type = type;
        }

        public void set(String type, String value) {
            switch (type) {
                case "name":
                    setName(value);
                    break;
                case "parentId":
                    int parentId = Integer.parseInt(value);
                    setParentId(parentId);
                    break;
                case "pid":
                    int pid = Integer.parseInt(value);
                    setPid(pid);
                    break;
                case "type":
                    int typeValue = Integer.parseInt(value);
                    setType(typeValue);
                    break;
            }
        }

        @Override
        public String getPickerViewText() {
            return name;
        }
    }
}
